﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace DAL
{
    public class PriceProduct
    {
        public static PriceProductEntity pricecontrast(PriceProductEntity priceproductentity)
        {
            DataRow dr = DbHelper.ExecuteDataRow("P_PriceContrast", priceproductentity.ProductId, priceproductentity.BusinessNature, priceproductentity.Price);
            PriceProductEntity ppentity = new PriceProductEntity();
            ppentity.ProductId = priceproductentity.ProductId;
            ppentity.BusinessNature = priceproductentity.BusinessNature;
            ppentity.Price = priceproductentity.Price;
            if (dr != null)
            {
                ppentity.ProductName = dr["productname"].ToString();
                ppentity.PriceDifference = Convert.ToDouble(dr["pricedifference"].ToString());
                ppentity.BusinessNatureName = dr["name"].ToString();
                ppentity.ContrastPrice = Convert.ToDouble(dr["contrastprice"].ToString());
                ppentity.SellerPrice = Convert.ToDouble(dr["sellerprice"].ToString());

            }
            else
            {
                ppentity.ProductName = null;
            }

            return ppentity;
        }
    }
}
